package com.crazy.web.controller.member;

import com.crazy.enums.Constants;
import com.crazy.model.major.dto.Menu;
import com.crazy.model.major.dto.UserSession;
import com.crazy.rest.RestResult;
import com.crazy.web.controller.BaseController;
import com.crazy.web.service.user.PermissionService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 菜单相关接口
 * @author zhaochaofeng
 * @version 1.0
 * @date 2020/11/19 16:03
 */
@Controller
@Log4j2
@RequestMapping("/member/menu")
public class MenuController extends BaseController {

    @Autowired
    private PermissionService permissionService;

    /**
     * 获取用户的菜单列表
     * @return
     */
    @GetMapping("/getMenus")
    public RestResult getMenus() {
        UserSession userSession = getUserSession();
        List<Menu> menus = permissionService.getMenus(userSession.getId());
        return RestResult.createSuccessResult("查询成功", menus);
    }

}
